package com.fowo.api.controller.handleWork;

import com.fowo.api.common.model.R;
import com.fowo.api.model.funds.pay.order.FundsPayOrderVo;
import com.fowo.api.service.handleWork.FundsPayPoolService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "请款池自定义接口")
@RequestMapping("/api/funds-pay-pool")
@RestController
public class FundsPayPoolController {

    @Resource
    private FundsPayPoolService service;

//    @PreAuthorize("@am.canAccess('loanNowBalanceRequestPayout')")
    @Operation(summary = "请款")
    @PostMapping("/request-payout")
    public R requestPayout(@RequestBody FundsPayOrderVo param) {
        return R.run(() -> service.requestPayout(param));
    }

//    @PreAuthorize("@am.canAccess('loanNowBalanceRequestPayout')")
    @Operation(summary = "批量请款")
    @PostMapping("/batch")
    public R batchRequestPayout(@RequestBody List<FundsPayOrderVo> params) {
        return R.run(() -> service.batchRequestPayout(params));
    }
}
